FSW_C2C	= fsw_c2c.x
FSW_R2R	= fsw_r2r.x
FSW_LT	= fsw_lt.x

#List of sources
C_FSW_R2R	= main.c ffts_r2r.c prep.c
C_FSW_C2C	= main.c ffts_c2c.c prep.c
C_FSW_LT	= main.c ffts_alt.c prep.c

# Compilers
CC      = gcc-4.8
LINK    = gcc-4.8
OPT     = -march=native -Ofast -flto -std=gnu99 -W -Wcast-qual -Wpointer-arith -Wcast-align -fno-schedule-insns -fschedule-insns2 -fstrict-aliasing -funroll-loops -fprefetch-loop-arrays -fomit-frame-pointer 

#-----------------------------
#generic

LIB_MPI         =
LIB_FFT         = -L/home/orange/fftw3libd/lib -lfftw3 -lm 
INC_MPI         =
INC_FFT         = -I/home/orange/fftw3libd/include
LIB_ADD         =

ifeq ($(HOSTNAME), pequena)
        LIB_MPI         =
        LIB_FFT         = -lfftw3_mpi -lfftw3 -lm
        INC_MPI         =
        INC_FFT         =
endif
ifeq ($(HOSTNAME), metropolis.RR)
        LIB_MPI         =
        LIB_FFT         = -L/opt/local/fftw/3.3.1/mvapich2/1.7/intel/12.1/lib -lfftw3_mpi -lfftw3 -lm
        INC_MPI         =
        INC_FFT         =
endif

#-----------------------------

OBJ_FSW_C2C	= $(C_FSW_C2C:.c=.o) $(F_FSW_C2C:.f=.o)
OBJ_FSW_R2R	= $(C_FSW_R2R:.c=.o) $(F_FSW_R2R:.f=.o)
OBJ_FSW_LT	= $(C_FSW_LT:.c=.o) $(F_FSW_LT:.f=.o)


LIB_FSW         = $(LIB_MPI) $(LIB_FFT) $(LIB_ADD)
INC_FSW         = $(INC_MPI) $(INC_FFT)

#-----------------------------

default: fsw_c2c

.f.o:
	$(FC) $(FFLAGS) -c $<

fsw_c2c:
	$(CC) $(OPT) $(DEF_FSW) $(INC_FSW) -c $(C_FSW_C2C)
	$(LINK) $(OPT) $(OBJ_FSW_C2C) $(LIB_FSW) -o $(FSW_C2C)

fsw_r2r:
	$(CC) $(OPT) $(DEF_FSW) $(INC_FSW) -c $(C_FSW_R2R)
	$(LINK) $(OPT) $(OBJ_FSW_R2R) $(LIB_FSW) -o $(FSW_R2R)

fsw_lt:
	$(CC) $(OPT) $(DEF_FSW) $(INC_FSW) -c $(C_FSW_LT)
	$(LINK) $(OPT) $(OBJ_FSW_LT) $(LIB_FSW) -o $(FSW_LT)

hostname:
	@echo $(HOSTNAME) $(INC_FFT)

clean:
	@echo "cleaning ..."
	rm -f *~ *.o

#-------------------------------


